package com.example.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
@RequestMapping("/user9")
@RestController
public class User9 {
    @RequestMapping("/file")
    public String upfile(@RequestPart("myfile") MultipartFile file) throws IOException {
        String path = "D:\\aaa\\img.png";
        // 把文件保存到path路径
        file.transferTo(new File(path));
        return path;
    }
}
